import propTypes from "prop-types"
let List = function (props) {

    console.log(props);

    let { list,flag } = props;//接受父组件传递过来的数据

    return (
        <div>
            {
                flag ?
                    (
                        <ul className='ul'>
                            {
                                list.map((item, index) => {
                                    return (
                                        <li onClick={() => props.setVal(item)} key={index}>{item}</li>
                                    )
                                })
                            }
                        </ul>
                    )
                    :
                    <></>
            }
        </div>
    )
}

//props接受的时候的数据类型校验
List.propTypes = {
    list: propTypes.array
}
export default List;